<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js">
    </script>
</head>
<body>
<div id="app">
    <input type="text" v-my-focus>
    <button>百度一下</button>
</div>

<script>
    Vue.directive(
        "my-focus", {
            inserted(elem) {
                elem.focus();
            }
        }
    );
    var vm = new Vue({
        el: "#app",
        data: {}
    })
</script>
</body>
</html>